package com.Tradition.config;


import com.Tradition.common.aop.annotation.Di;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;

@Aspect
@Component
public class diAopAspect {
    @Before("@annotation(fashion.deja.common.aop.annotation.Di)")
    public void before(JoinPoint joinPoint) {
        MethodSignature signature = (MethodSignature) joinPoint.getSignature();
        Method method = signature.getMethod();
        Di di = method.getAnnotation(Di.class); //已知可以获取被切入方法的参数，但是无法根据名称获取
        System.out.println("注解式拦截 " + di);
    }

}
